package cn.javase.base.internet._03_UDP通讯;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class Receive {
    public static void main(String[] args) throws IOException {
        DatagramSocket socket = new DatagramSocket(8090);
        byte[] buf = new byte[1024];
        DatagramPacket packet = new DatagramPacket(buf, 0, buf.length);
        socket.receive(packet);
        String data = new String(buf, 0, packet.getLength());
        System.out.println("接受到数据：" + new String(data));
        socket.close();
    }
}
